/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TaskSpyApp.java
 *
 * Created on Jun 22, 2012, 10:16:27 PM
 */
package taskspydelux;

import com.skstudio.network.TaskSpyClient;

/**
 *
 * @author wenwei
 */
public class TaskSpyApp extends javax.swing.JFrame {

    /** Creates new form TaskSpyApp */
    public TaskSpyApp() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        rootPanel = new javax.swing.JPanel();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        openMenuItem = new javax.swing.JMenuItem();
        saveMenuItem = new javax.swing.JMenuItem();
        saveAsMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        cutMenuItem = new javax.swing.JMenuItem();
        copyMenuItem = new javax.swing.JMenuItem();
        pasteMenuItem = new javax.swing.JMenuItem();
        deleteMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        contentsMenuItem = new javax.swing.JMenuItem();
        aboutMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(720, 320));

        jScrollPane1.setFocusTraversalPolicyProvider(true);
        jScrollPane1.setName("jScrollPane1"); // NOI18N

        rootPanel.setName("rootPanel"); // NOI18N
        rootPanel.setLayout(new javax.swing.BoxLayout(rootPanel, javax.swing.BoxLayout.Y_AXIS));
        jScrollPane1.setViewportView(rootPanel);

        fileMenu.setText("File");

        openMenuItem.setText("Open");
        fileMenu.add(openMenuItem);

        saveMenuItem.setText("Save");
        fileMenu.add(saveMenuItem);

        saveAsMenuItem.setText("Save As ...");
        fileMenu.add(saveAsMenuItem);

        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        editMenu.setText("Edit");

        cutMenuItem.setText("Cut");
        editMenu.add(cutMenuItem);

        copyMenuItem.setText("Copy");
        editMenu.add(copyMenuItem);

        pasteMenuItem.setText("Paste");
        editMenu.add(pasteMenuItem);

        deleteMenuItem.setText("Delete");
        editMenu.add(deleteMenuItem);

        menuBar.add(editMenu);

        helpMenu.setText("Help");

        contentsMenuItem.setText("Contents");
        helpMenu.add(contentsMenuItem);

        aboutMenuItem.setText("About");
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 785, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 785, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 529, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 529, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed
    static TaskSpyClient client = null;

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                TaskSpyApp tsp = new TaskSpyApp();
                tsp.setVisible(true);

                client = new TaskSpyClient(tsp.rootPanel);
                tsp.setupThreadsView();
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JMenuItem contentsMenuItem;
    private javax.swing.JMenuItem copyMenuItem;
    private javax.swing.JMenuItem cutMenuItem;
    private javax.swing.JMenuItem deleteMenuItem;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JMenuItem pasteMenuItem;
    private javax.swing.JPanel rootPanel;
    private javax.swing.JMenuItem saveAsMenuItem;
    private javax.swing.JMenuItem saveMenuItem;
    // End of variables declaration//GEN-END:variables
    uiChartViewProcess mViewProcess = null;
    uiChartViewThreads mViewThreads = null;
    uiChartViewProcMem mViewProcMem = null;
    uiChartViewCpu     mViewCpu = null;
    uiChartViewCores   mViewCores = null;
    uiChartViewCoreFreq mViewCoreFreq = null;
    uiChartViewSysMem   mViewSysMem = null;
    uiChartViewWifiThru mViewWifiThru = null;
    uiChartViewWifiSignal mViewWifiSignal = null;
    uiChartViewCellularThru mViewCellular = null;
    uiChartViewBattery mViewBattery = null;

    public void setupThreadsView() {
        mViewCpu = new uiChartViewCpu();
        mViewCpu.setVisible(true);
        rootPanel.add(mViewCpu);

        mViewCores = new uiChartViewCores();
        mViewCores.setVisible(true);
        rootPanel.add(mViewCores);

        mViewCoreFreq = new uiChartViewCoreFreq();
        mViewCoreFreq.setVisible(true);
        rootPanel.add(mViewCoreFreq);

        mViewSysMem = new uiChartViewSysMem();
        mViewSysMem.setVisible(true);
        rootPanel.add(mViewSysMem);

        mViewProcess = new uiChartViewProcess();
        mViewProcess.setVisible(true);
        rootPanel.add(mViewProcess);

        mViewThreads = new uiChartViewThreads();
        mViewThreads.setVisible(true);
        rootPanel.add(mViewThreads);

        mViewProcMem = new uiChartViewProcMem();
        mViewProcMem.setVisible(true);
        rootPanel.add(mViewProcMem);

        mViewWifiThru = new uiChartViewWifiThru();
        mViewWifiThru.setVisible(true);
        rootPanel.add(mViewWifiThru);

        mViewWifiSignal = new uiChartViewWifiSignal();
        mViewWifiSignal.setVisible(true);
        rootPanel.add(mViewWifiSignal);

        mViewCellular = new uiChartViewCellularThru();
        mViewCellular.setVisible(true);
        rootPanel.add(mViewCellular);

        mViewBattery = new uiChartViewBattery();
        mViewBattery.setVisible(true);
        rootPanel.add(mViewBattery);

        validate();

        mViewCpu.getChart().setViewController(client.getReSysCpu());
        mViewCores.getChart().setViewController(client.getReCores());
        mViewCoreFreq.getChart().setViewController(client.getReCoreSpeed());
        mViewSysMem.getChart().setViewController(client.getReSysMem());
        mViewProcess.getChart().setViewController(client.getReProcess());
        mViewThreads.getChart().setViewController(client.getReProcessThread());
        mViewProcMem.getChart().setViewController(client.getReProcessMem());
        mViewWifiThru.getChart().setViewController(client.getReNetworkThru());
        mViewWifiSignal.getChart().setViewController(client.getReWifi());
        mViewCellular.getChart().setViewController(client.getReCellularThru());
        mViewBattery.getChart().setViewController(client.getReBattery());

        client.start();
    }
}
